function [stim, fsv, fdel, fsl, fisi, cap] = txt_read(arg)
%
% function to read the analyzed textual output of a NEURON run into arrays
% 12/22/98 P. Manis
%
% use wildload to get the filenames in the list
% 1/26/99 P. Manis
% 2/2/99 P. Manis Modified from neuron_read to read the text files...
%
nl = 0;
stim = [];
fsl = [];
fisi = [];
fdel = [];
cap = [];
path = 'd:\nrn\Pok\'
if(nargin == 0)
   [type, ok] = listdlg('ListString', 'hypr|hyph|hypp|hy2r|hy2h|hy2p', 'Prompt', 'Select NEURON run to import', ...
   'SelectionMode', 'single', 'Name', 'NEURON Data Import');
if(~ok)
   return
end
else
   switch(arg)
   case 'r1'
      type = 1
   case 'h1'
      type = 2
   case 'p1'
      type = 3
   case '2a'
      type = 4
   case '2d'
      type = 5
   case '2c'
      type = 6
   end
end



switch(type)
case 1
   np = strcat(path, 'hypr*.txt')
case 2
   np = strcat(path, 'hyph*.txt')
case 3
   np = strcat(path, 'hypp*.txt')
case 4
   np = strcat(path, 'hy2a*.txt')
case 5
   np = strcat(path, 'hy2d*.txt')
case 6
   np = strcat(path, 'hy2p*.txt')
otherwise
end
list = wildload(np);

nl=size(list);
if(nl(1) == 0)
   disp('No Files Found')
   return
end
disp(sprintf('Importing %d files', nl(2)));
DFILE = init_dfile(nl(1));

for i=1:nl(1) % do this in your own program to get the data where it belongs.
   disp(sprintf('txt_READ %s', list(i).name))
   A=load([path, list(i).name]);
   sA = size(A);
   stim(i,:)=A(1,:);
   fsv(i,:) = A(2,:);
   fsl(i,:)=A(3,:);
   fisi(i,:)=A(4,:);
   fdel(i,:) = A(5,:);
   cap(i,:) = A(6,:);
end
stim = stim';
fsl = fsl';
fisi = fisi';
fsv = fsv';
fdel = fdel';
cap = cap';


   